package com.example.project.projectspringcloud.controller.front.branddetail;

import com.example.project.projectspringcloud.controller.BaseController;
import com.example.project.projectspringcloud.entity.sys.SysConfig;
import com.example.project.projectspringcloud.service.sys.SysConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * 品牌介绍
 */
@Api(tags = "品牌介绍控制器")
@Controller
@RequestMapping(value = "/brand")
public class BrandController extends BaseController {

    @Autowired
    private SysConfigService sysConfigService;

    /**
     * @return
     * @throws Exception
     */
    @ApiOperation(value = "品牌介绍列表", notes = "返回品牌介绍列表")
    @GetMapping(value = {"", "/list"})
    public String list(@RequestParam("type") String type, @RequestParam("m") Integer m, Model model) {

        model.addAttribute("type", type);
        model.addAttribute("m", m);

        switch (type) {
            case "about":
                model.addAttribute("list", sysConfigService.list(null, new SysConfig("footer-about")));
                break;
            case "business":
                model.addAttribute("list", sysConfigService.list(null, new SysConfig("footer-business")));
                break;
            case "join":
                model.addAttribute("list", sysConfigService.list(null, new SysConfig("footer-join")));
                break;
            case "platform":
                model.addAttribute("list", sysConfigService.list(null, new SysConfig("footer-platform")));
                break;
            default:
                break;
        }

        /*model.addAttribute("luaAgreement", sysConfigService.get(new SysConfig("lua-agreement")));
        model.addAttribute("privateAgreement", sysConfigService.get(new SysConfig("private-agreement")));
        model.addAttribute("securityAgreement", sysConfigService.get(new SysConfig("security-agreement")));*/
        return isMobile() ? "m/content/about" : "content/brand-introduce";
    }
}
